package com.sky.controller.user;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.SetmealDish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealDishVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
@Api(tags = "套餐相关接口")
public class SetmealController {
    @Autowired
    SetmealService setmealService;

    @ApiOperation("根据分类id查询套餐")
    @GetMapping("/list")
    @Cacheable(cacheNames = "setmealCache",key = "#categoryId") //setmealCache::101
    public Result getByCategoryId(Long categoryId){
        return Result.success(setmealService.findByCategoryId(categoryId));
    }

    @ApiOperation("查询套餐包含的内容")
    @GetMapping("/dish/{id}")
    public Result<List<SetmealDishVO>> getDishs(@PathVariable Integer id){
        List<SetmealDishVO> vo=setmealService.getDishs(id);
        return Result.success(vo);
    }

}
